package eu.jpereira.trainings.designpatterns.creational.builder.html;

import java.util.Iterator;

import eu.jpereira.trainings.designpatterns.creational.builder.ReportBodyBuilder;
import eu.jpereira.trainings.designpatterns.creational.builder.model.ReportBody;

public class HTMLReportBodyBuilder extends ReportBodyBuilder
{
       
        private HTMLReportBody reportBody = new HTMLReportBody();

        public ReportBody getReportBody()
        {
                reportBody.putContent("<span class=\"customerName\">");
                reportBody.putContent(customerName);
                reportBody.putContent("</span><span class=\"customerPhone\">");
                reportBody.putContent(phoneNumber);
                reportBody.putContent("</span>");
                reportBody.putContent("<items>");
                Iterator<Item> it = soldItems.iterator();
                while ( it.hasNext() )
                {
                        Item item = it.next();
                        reportBody.putContent("<item><name>");
                        reportBody.putContent(item.name);
                        reportBody.putContent("</name><quantity>");
                        reportBody.putContent(item.quantity);
                        reportBody.putContent("</quantity><price>");
                        reportBody.putContent(item.price);
                        reportBody.putContent("</price></item>");
                }
                reportBody.putContent("</items>");
               
                return reportBody;
        }

}
